{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2940
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	v,t,s:int64;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(v,t);
s:=abs(v)*t;
if  (s mod 109=0) then write(0) else
if v>0 then write(s mod 109) else write(109-s mod 109);
end.
 